<template>
  <div id="index" ref="appRef" style="width: 600px">
    <centerLeft2 />
    {{data}}
  </div>
</template>

<script>
import drawMixin from "../utils//drawMixin";
import { formatTime1 } from '@/utils'
import centerLeft1 from './index/centerLeft1'
import centerLeft2 from './index/centerLeft2'
import centerRight1 from './index/centerRight1'
import centerRight2 from './index/centerRight2'
import center from './index/center'
import bottomLeft from './index/bottomLeft'
import bottomRight from './index/bottomRight'
import {getArea} from "@/api/system/factory";
export default {
  mixins: [ drawMixin ],
  data() {
    return {
      data:[],
      timing: null,
      loading: true,
      dateDay: null,
      dateYear: null,
      dateWeek: null,
      weekday: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
      decorationColor: ['#568aea', '#000000']
    }
  },
  components: {
    centerLeft1,
    centerLeft2,
    centerRight1,
    centerRight2,
    center,
    bottomLeft,
    bottomRight
  },
  mounted() {
    this.timeFn()
    this.cancelLoading()
    this.getData()
  },
  beforeDestroy () {
    clearInterval(this.timing)
  },
  methods: {
    getData(){
      getArea().then(res =>{
        this.data = res
      })
    },
    timeFn() {
      this.timing = setInterval(() => {
        this.dateDay = formatTime1(new Date(), 'HH: mm: ss')
        this.dateYear = formatTime1(new Date(), 'yyyy-MM-dd')
        this.dateWeek = this.weekday[new Date().getDay()]
      }, 1000)
    },
    cancelLoading() {
      setTimeout(() => {
        this.loading = false
      }, 500)
    }
  }
}
</script>

<style lang="scss" scoped>
@import '../assets/scss/index.scss';
</style>

